<template>
  <el-row>
    <el-row>
      <el-table
        :data="tableData"
        :cell-style="$rowstyle"
        :header-cell-style="$headerstyle"
        :fit="true"
        border
        style="width: 100%"
      >
        <el-table-column prop="code" label="合同号" width="70"></el-table-column>
        <el-table-column prop="name" label="合同名称"></el-table-column>
        <el-table-column prop="name" label="周期">
          <template slot-scope="scope">
            <span>{{transDate(scope.row.cycle.start_time)}}~{{transDate(scope.row.cycle.end_time)}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="get_agent.name" label="代理商"></el-table-column>
        <el-table-column prop="get_media_up.name" label="广告主"></el-table-column>
        <el-table-column prop="money" label="合同总金额(万元)" width="100"></el-table-column>
        <el-table-column prop="note" label="备注"></el-table-column>
        <el-table-column prop="status" label="状态">
          <template slot-scope="scope">
           <span v-if="scope.row.status == 1">草稿</span>
           <span v-if="scope.row.status == 2" style="color:red;">提交审核</span>
           <span v-if="scope.row.status == 3" style="color:green;">通过</span>
           <span v-if="scope.row.status == 4">拒绝</span>
           <span v-if="scope.row.status == 5">终止合同</span>
           <span v-if="scope.row.status == 6">暂停合同</span>
          </template>
        </el-table-column>
        <el-table-column prop="date" label="制作时间" width="100">
           <template slot-scope="scope">
            <span>{{transDate(scope.row.date)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="补播" width="60">
          <template slot-scope="scope">
            <el-button @click="addPlay(scope.row)" type="text" size="small">添加</el-button>
          </template>
        </el-table-column>
        <!-- <el-table-column label="回款记录" width="60">
          <template slot-scope="scope">
            <el-button @click="addRefundMoney(scope.row)" type="text" size="small">添加</el-button>
          </template>
        </el-table-column> -->
        <el-table-column label="编辑" width="95">
          <template slot-scope="scope">
            <el-button @click="handleCheck(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" @click="handleEdit(scope.row)" size="small">编辑</el-button>
          </template>
        </el-table-column>
        <el-table-column label="播出结果" width="90">
          <template slot-scope="scope">
            <el-button @click="handleResultOfPlay(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" size="small" @click="handleResultUpload(scope.row)">上传</el-button>
          </template>
        </el-table-column>
        <el-table-column label="预排期" width="60">
          <template slot-scope="scope">
            <el-button @click="HandlePreSchedule(scope.row)" type="text" size="small">设置</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>

  </el-row>
</template>

<script>
import { getBuildContract } from "../../../api/Salesman.js";
import { SETDATE } from "../../../api/System.js";
import moment from 'moment'
export default {
  props: ["tableData"],
  data() {
    return {

      listData:[]
    };
  },
  methods: {
    transDate(time){

     return moment.unix(String(time)).format('YYYY-MM-DD')
    },
    addPlay(data){
      this.$emit('addPlay',data)
    },
    addRefundMoney(data){
      this.$emit('addRefundMoney',data)
    },
    handleCheck(data){
      this.$emit('handleCheck',data)
    },
    handleEdit(data){
      this.$emit('handleEdit',data)
    },
    handleResultOfPlay(data){
      this.$emit('handleResultOfPlay',data)
    },
    HandlePreSchedule(data){
      this.$emit('HandlePreSchedule',data)
    },
   handleResultUpload(data){
     this.$emit('handleResultUpload',data)
   }
    // getContractList() {
    //   let params = {
    //     page: this.currentPage,
    //     per: this.per
    //   };
    //   getBuildContract(params).then(res => {
    //     console.log(res);
    //     if (res.code == 200) {
    //       this.listData = res.data.data;
    //       this.currentPage = res.data.current_page;
    //       this.total = res.data.total;
    //       this.listData.forEach(element => {
    //         element.cycle = JSON.parse(element.cycle);
    //         for (const key in element.cycle) {
    //           if (element.cycle.hasOwnProperty(key)) {
    //             const el = element.cycle[key];
    //             element.cycle[key] = SETDATE(el, true);
    //           }
    //         }
    //       });
    //     }
    //   });
    // }

  },
  mounted(){
    // this.getContractList()
  },

};
</script>

<style scoped>
</style>
